/*
package org.jivesoftware.openfire.plugin;

*/
/**
 * @Discription ${在此输入一句话描述此文件的作用}
 * @Author yang jun
 * @Date 2019/4/30 16:42
 *//*

import java.util.Hashtable;

import java.util.Properties;

import javax.sip.*;

import javax.sip.address.AddressFactory;

import javax.sip.address.URI;

import javax.sip.header.HeaderFactory;

import javax.sip.message.MessageFactory;

import javax.sip.message.Request;

import javax.sip.message.Response;

         

public class SipManager implements SipListener {

         

public static Hashtable<String, URI> allUsers = new Hashtable<String, URI>();

public static String ipAddr = "172.16.7.85";

public static int port = 8888;

         

public static SipStack sipStack = null;

         

public static AddressFactory addressFactory = null;

         

public static MessageFactory msgFactory = null;

         

public static HeaderFactory headerFactory = null;

         

public static SipProvider sipProvider = null;

         

//以下三个变量需要根据Call-ID进行统一匹配管理

public static ServerTransaction serverTransactionId = null;

public static Dialog callerDialog = null;

public static Dialog calleeDialog = null;

         

private void init() {

        SipFactory sipFactory = null;

        sipFactory = SipFactory.getInstance();

        if (null == sipFactory) {

        System.out.println("init sipFactory is null.");

        return;

        }

        sipFactory.setPathName("gov.nist");

        Properties properties = new Properties();

        properties.setProperty("javax.sip.STACK_NAME", "sipphone");

        properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");

        properties.setProperty("gov.nist.javax.sip.DEBUG_LOG",

        "sipphonedebug.txt");

        properties.setProperty("gov.nist.javax.sip.SERVER_LOG",

        "sipphonelog.txt");

        try {

        sipStack = sipFactory.createSipStack(properties);

        } catch (PeerUnavailableException e) {

// TODO Auto-generated catch block

        e.printStackTrace();

        return;

        }

        try {

        headerFactory = sipFactory.createHeaderFactory();

        addressFactory = sipFactory.createAddressFactory();

        msgFactory = sipFactory.createMessageFactory();

        ListeningPoint udp = sipStack.createListeningPoint(ipAddr,

        port, "udp");

//ListeningPoint tcp = sipStack.createListeningPoint(ipAddr,

//port, "tcp");

        SipManager listener = this;

         

        sipProvider = sipStack.createSipProvider(udp);

        System.out.println("udp provider " + sipProvider.toString());

        sipProvider.addSipListener(listener);

//sipProvider = sipStack.createSipProvider(tcp);

//System.out.println("tcp provider " + sipProvider.toString());

        sipProvider.addSipListener(listener);

//

        } catch (Exception ex) {

        ex.printStackTrace();

        return;

        }

         

        }

public static void main(String[] args) {

        new SipManager().init();

        }

@Override

public void processDialogTerminated(DialogTerminatedEvent arg0) {

// TODO Auto-generated method stub

        }

@Override

public void processIOException(IOExceptionEvent arg0) {

// TODO Auto-generated method stub

        }

@Override

public void processRequest(RequestEvent arg0) {

// TODO Auto-generated method stub

        Request request = arg0.getRequest();

        if (null == request) {

        System.out.println("processRequest request is null.");

        return;

        }

         

        if (Request.INVITE.equals(request.getMethod())) {

        System.out.println("收到呼叫请求");

        SipInvite.invite(request, arg0);

        } else if (Request.REGISTER.equals(request.getMethod())) {

        System.out.println("注册请求");

        SipRegister.register(request, arg0);

        } else if (Request.SUBSCRIBE.equals(request.getMethod())) {

        } else if (Request.ACK.equalsIgnoreCase(request.getMethod())) {

        System.out.println("ACK请求");

        SipAck.ack(request, arg0);

        } else if (Request.BYE.equalsIgnoreCase(request.getMethod())) {

        System.out.println("Bye请求");

        SipBye.bye(request, arg0);

        } else if (Request.CANCEL.equalsIgnoreCase(request.getMethod())) {

        } else if (Request.OPTIONS.equalsIgnoreCase(request.getMethod())) {

        System.out.println("收到心跳检测");

        SipOption.option(request, arg0);

        } else if (Request.SUBSCRIBE.equalsIgnoreCase(request.getMethod())) {

        System.out.println("收到订阅信息");

        } else {

        System.out.println("no support the method!");

        }

        }

@Override

public void processResponse(ResponseEvent arg0) {

// TODO Auto-generated method stub

        Response response = arg0.getResponse();

        if (response.getStatusCode() == Response.RINGING) {

        System.out.println("收到Ringing");

        SipResponseRing.ring(response, arg0);

        } else if (response.getStatusCode() == Response.OK) {

        System.out.println("收到200OK");

        SipResponseOK.ok(response, arg0);

        }

        }

@Override

public void processTimeout(TimeoutEvent arg0) {

// TODO Auto-generated method stub

        }

@Override

public void processTransactionTerminated(TransactionTerminatedEvent arg0) {

// TODO Auto-generated method stub

        }

         

}

*/
